﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="LocationPage.aspx.cs" Inherits="FBKPI.Pages.LocationPage" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
<script type="text/javascript">
    $(document).ready(function () {
        mainmenu("#nav ul", "#nav li");
        mainmenu("#menu_wrap ul", "#menu_wrap li");
        $("#divdetail").hide();
        $("#divdetail").dialog({
            title: '<span class="header-text">Branch Form</span>',
            autoOpen: false,
            width: 600,
            height: 270,
            modal: true,
            resizable: false
        });


        //datatable section
        $("#LocationTable").dataTable({
            "oLanguage": {
                "sZeroRecords": "No records to display",
                "sSearch": "Search"
            },
            "bSort": true,
            "bPaginate": true,
            "bAutoWidth": false,
            "bProcessing": true,
            "bServerSide": true,
            "bDestroy": true,
            "bJQueryUI": true,
            "sPaginationType": "full_numbers",
            "bDeferRender": true,
            "fnServerData": function (sSource, aoData, fnCallback) {
                $.ajax({
                    "dataType": 'json',
                    "type": "GET",
                    "url": "../Serializer/LocationSerializer.ashx?CurrUser=" + $("#txt_user").val(),
                    "data": aoData,
                    "success": fnCallback
                });
            },
            "aoColumns": [
            {
                "mData": "ID", "sWidth": "8%"
            },
            {
                "mData": "No", "sWidth": "5%"
            }, {
                "mData": "Description"
            }, {
                "mData": "ORGID"
            }
            , {
                "mData": "RGM"
            },
            
             {
                "mData": "isHeadOffice", "sWidth": "10%"
            }
            ,
             {
                 "mData": "isActive", "sWidth": "10%"
             }
            
            , {
                "mData": "LastModifiedDate"
            }, {
                "mData": "LastModifiedBy"
            }, {
                "mData": "CreateDate"
            }, {
                "mData": "CreateBy"
            },  ],
            "aoColumnDefs": [{
                "fnRender": function (oObj) {
                    //return "<a href=\"#\" onclick=\"OnDetail('" + oObj.aData["ID"] + "')\">Edit</a>&nbsp;/<a href=\"#\" onclick=\"OnDelete('" + oObj.aData["ID"] + "')\">Delete</a>";
                    return "<a href=\"#\" onclick=\"OnDetail('" + oObj.aData["ID"] + "')\"><img src='../images/icon_edit.png' title='Edit Data' /></a>&nbsp;<a href=\"#\" onclick=\"OnDelete('" + oObj.aData["ID"] + "')\"><img src='../images/icon_delete.png' title='Delete Data' /></a>";
                },
                "aTargets": [0]
            }, {
                "fnRender": function (oObj) {
                    if (oObj.aData["isActive"] == 'True') {
                        return "<img src='../images/check.png' />"
                    } else {
                        return "<img src='../images/cross.png' />"
                    }
                },
                "aTargets": [6]
            }, {
                "fnRender": function (oObj) {
                    if (oObj.aData["isHeadOffice"] == 'True') {
                        return "<img src='../images/check.png' />"
                    } else {
                        return "<img src='../images/cross.png' />"
                    }
                },
                "aTargets": [5]
            },
            {
                "bVisible": false,
                "aTargets": [ 7, 8, 9,10]
            },
             {
                "sClass": "center",
                "aTargets": [0, 1,   5,6, 7, 9]
            }]
        });

        //mark selected row
        $('body').on("click", '#LocationTable tbody tr', function () {
            $('#LocationTable tbody tr').removeClass("row_selected");
            $(this).addClass("row_selected");
        });
        //--------------------end of mark selected row-----------------------------
        $("#LocationTable_length label").after('&nbsp;<button id=\"btnAddNew\" class="button add" style="right: 0px;" onclick=\'OnDetail(0);return false;\'>New Record</button>');
        //--------------------end of datatable section-----------------------------------------

        OnDetail = function (code) {
            LoadForm('LocationForm.aspx?ID=' + code, function (result) {
                $("#divdetail").html(result);
                $("#divdetail").dialog('open');
            });
            return false;
        }

        OnDelete = function (code) {
            $.msgBox.confirm("Benar data akan dihapus ?", function () {
                var param = "?";
                param = param + "action=delete";
                param = param + "&ID=" + code;
                param = param + "&CurrUser=" + $("#txt_user").val();
                ProcessRequest("LocationHandler.ashx" + param, "#divdetail", "#LocationTable");
                return false;
            }, false);

            return false;
        }
    });
</script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<div style="height:525px;overflow:auto;" >
    <div id="locationtable">
        <div>
            <div class="customPageHeader">
                <span class="customPageTitle">Branch</span>
            </div>
            <div class="ui-widget-content">
                <table cellpadding="0" cellspacing="0" class="display" id="LocationTable">
                    <thead>
                        <tr>
                         <th>
                         Action
                            </th>
                            <th>
                                No
                            </th>
                            <th>
                                Description
                            </th>
                            <th>
                                ORG ID
                            </th>
                            <th>
                                RGM
                            </th>
                            <th>
                                is Head Office
                            </th>
                             <th>
                                is Active
                            </th>
                           
                            <th>
                                Last Update Date
                            </th>
                            <th>
                                Last Updated By
                            </th>
                            <th>
                                Creation Date
                            </th>
                            <th>
                                Created By
                            </th>
                           
                        </tr>
                    </thead>
                    <tbody>
                    </tbody>
                </table>       
            </div>
        </div>
        <br />
    </div>
    <div id="divdetail"></div>   
    </div> 
</asp:Content>
